<?php
	/**
	 * 
	 * Type model
	 * @author Vu Tran
	 *
	 */
	class TypeModel extends Model
	{
		/**
		 * Constructor
		 */
		function __construct()
		{
			parent::__construct();
		}
		
		/**
		 * 
		 * Gets all record from table Type
		 */
		function getAllTypes()
		{
			$sql = "select * from type t order by t.position asc";
			return $this->execute_query($sql);
		}
		
		/**
		 * 
		 * Gets a specific type by id
		 * @param string $id
		 */
		function getTypeById($id){
			$sql = "select * from type where id = ?";
			$values = array();
			$values[0] = $id;
			$types = array();
			$types[0] = "integer";
			$res = $this->execute_query($sql, $values, $types);
			if(is_array($res) && count($res) > 0){
				return $res[0];
			}
			return null;
		}
	}
?>